<%--@elvariable id="countTrash" type="java.lang"--%>
<%--@elvariable id="countDraft" type="java.lang"--%>
<%--@elvariable id="countSent" type="java.lang"--%>
<%--@elvariable id="countInbox" type="java.lang"--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
    <%@include file="../../common.jsp" %>

    <!-- BEGIN PAGE LEVEL STYLES -->
    <link href="assets/plugins/bootstrap-wysihtml5/bootstrap-wysihtml5.css" rel="stylesheet" type="text/css"/>
    <link href="assets/plugins/fancybox/source/jquery.fancybox.css" rel="stylesheet"/>
    <!-- BEGIN:File Upload Plugin CSS files-->
    <link href="assets/plugins/jquery-file-upload/blueimp-gallery/blueimp-gallery.min.css" rel="stylesheet"/>
    <link href="assets/plugins/jquery-file-upload/css/jquery.fileupload.css" rel="stylesheet"/>
    <link href="assets/plugins/jquery-file-upload/css/jquery.fileupload-ui.css" rel="stylesheet"/>
    <!-- END:File Upload Plugin CSS files-->
    <!-- END PAGE LEVEL STYLES -->
    <!-- BEGIN THEME STYLES -->
    <link href="assets/css/style-metronic.css" rel="stylesheet" type="text/css"/>
    <link href="assets/css/style.css" rel="stylesheet" type="text/css"/>
    <link href="assets/css/style-responsive.css" rel="stylesheet" type="text/css"/>
    <link href="assets/css/plugins.css" rel="stylesheet" type="text/css"/>
    <link href="assets/css/themes/default.css" rel="stylesheet" type="text/css" id="style_color"/>
    <link href="assets/css/pages/inbox.css" rel="stylesheet" type="text/css"/>
    <link href="assets/css/custom.css" rel="stylesheet" type="text/css"/>
    <!-- END THEME STYLES -->

    <link href="css/global/myStyle.css" rel="stylesheet" type="text/css"/>

</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body>

<!-- BEGIN CONTAINER -->
<div class="page-container">
    <!-- BEGIN CONTENT -->
    <div class="page-content-wrapper">
        <div class="page-content">
            <!-- BEGIN PAGE HEADER-->
            <div class="row">
                <div class="col-md-12">
                    <!-- BEGIN PAGE TITLE & BREADCRUMB-->
                    <h3 class="page-title">
                        信箱 <small>我的信箱</small>
                    </h3>
                    <ul class="page-breadcrumb breadcrumb">
                        <li class="btn-group">
                        </li>
                        <li>
                            <i class="fa fa-home"></i>
                            <a href="javascript:" onclick="top.addTab('public/menu')">
                                首页
                            </a>
                            <i class="fa fa-angle-right"></i>
                        </li>
                        <li>
                            <a href="javascript:"> 我的信箱 </a>
                        </li>
                        <li class="pull-right">
                            <span id="nowTime"></span>
                        </li>
                    </ul>
                    <!-- END PAGE TITLE & BREADCRUMB-->
                </div>
            </div>
            <div class="row inbox">
                <div class="col-md-2">
                    <ul class="inbox-nav margin-bottom-10">
                        <li class="compose-btn">
                            <a href="javascript:" data-title="Compose" class="btn green">
                                <i class="fa fa-edit"></i> 写邮件
                            </a>
                        </li>
                        <li class="inbox active">
                            <a href="javascript:" class="btn" id="countInboxBox" data-title="Inbox">
                                收信箱(${countInbox})
                            </a>
                            <input type="hidden" id="countInbox" value="(${countInbox}"/>
                            <b></b>
                        </li>
                        <li class="sent">
                            <a class="btn" href="javascript:" id="countSentBox" data-title="Sent">
                                发信箱(${countSent})
                            </a>
                            <input type="hidden" id="countSent" value="${countSent}"/>
                            <b></b>
                        </li>
                        <li class="draft">
                            <a class="btn" href="javascript:" id="countDraftBox" data-title="Draft">
                                草案箱(${countDraft})
                            </a>
                            <input type="hidden" id="countDraft" value="${countDraft}"/>
                            <b></b>
                        </li>
                        <li class="trash">
                            <a class="btn" href="javascript:" id="countTrashBox" data-title="Trash">
                                垃圾箱(${countTrash})
                            </a>
                            <input type="hidden" id="countTrash" value="${countTrash}"/>
                            <b></b>
                        </li>
                    </ul>
                </div>
                <div class="col-md-10">
                    <div class="inbox-header">
                        <h1 class="pull-left">收件箱</h1>
                    </div>
                    <div class="inbox-loading">
                        等待中...
                    </div>
                    <div class="inbox-content">

                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- END CONTENT -->
</div>
<!-- END CONTAINER -->

<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
<!-- BEGIN CORE PLUGINS -->
<!--[if lt IE 9]>
<script src="assets/plugins/respond.min.js"></script>
<script src="assets/plugins/excanvas.min.js"></script>
<![endif]-->
<script src="assets/plugins/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery.blockui.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery.cokie.min.js" type="text/javascript"></script>
<script src="assets/plugins/uniform/jquery.uniform.min.js" type="text/javascript"></script>
<!-- END CORE PLUGINS -->
<!-- BEGIN: Page level plugins -->
<script src="assets/plugins/fancybox/source/jquery.fancybox.pack.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap-wysihtml5/wysihtml5-0.3.0.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap-wysihtml5/bootstrap-wysihtml5.js" type="text/javascript"></script>
<!-- BEGIN:File Upload Plugin JS files-->
<!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included -->
<script src="assets/plugins/jquery-file-upload/js/vendor/jquery.ui.widget.js"></script>
<!-- The Templates plugin is included to render the upload/download listings -->
<script src="assets/plugins/jquery-file-upload/js/vendor/tmpl.min.js"></script>
<!-- The Load Image plugin is included for the preview images and image resizing functionality -->
<script src="assets/plugins/jquery-file-upload/js/vendor/load-image.min.js"></script>
<!-- The Canvas to Blob plugin is included for image resizing functionality -->
<script src="assets/plugins/jquery-file-upload/js/vendor/canvas-to-blob.min.js"></script>
<!-- blueimp Gallery script -->
<script src="assets/plugins/jquery-file-upload/blueimp-gallery/jquery.blueimp-gallery.min.js"></script>
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="assets/plugins/jquery-file-upload/js/jquery.iframe-transport.js"></script>
<!-- The basic File Upload plugin -->
<script src="assets/plugins/jquery-file-upload/js/jquery.fileupload.js"></script>
<!-- The File Upload processing plugin -->
<script src="assets/plugins/jquery-file-upload/js/jquery.fileupload-process.js"></script>
<!-- The File Upload image preview & resize plugin -->
<script src="assets/plugins/jquery-file-upload/js/jquery.fileupload-image.js"></script>
<!-- The File Upload audio preview plugin -->
<script src="assets/plugins/jquery-file-upload/js/jquery.fileupload-audio.js"></script>
<!-- The File Upload video preview plugin -->
<script src="assets/plugins/jquery-file-upload/js/jquery.fileupload-video.js"></script>
<!-- The File Upload validation plugin -->
<script src="assets/plugins/jquery-file-upload/js/jquery.fileupload-validate.js"></script>
<!-- The File Upload user interface plugin -->
<script src="assets/plugins/jquery-file-upload/js/jquery.fileupload-ui.js"></script>
<!-- The main application script -->
<!-- The XDomainRequest Transport is included for cross-domain file deletion for IE 8 and IE 9 -->
<!--[if (gte IE 8)&(lt IE 10)]>
<script src="assets/plugins/jquery-file-upload/js/cors/jquery.xdr-transport.js"></script>
<![endif]-->
<!-- END:File Upload Plugin JS files-->
<!-- END: Page level plugins -->
<script src="assets/scripts/core/app.js"></script>
<script src="js/person/inbox/inbox.js"></script>
<script>
    jQuery(document).ready(function () {
        // initiate layout and plugins
        var selectFriendId = 0;
        App.init();
        Inbox.init();
        parent.browserSizeDeal(7, document.body.clientHeight+100);
        window.setInterval(setNotePageTime, 1000);
    });

    function setNotePageTime() {
        $("#nowTime").html(top.getNowTime());
    }
    function refresh() {
        $('.inbox-nav > li.active > a').click();
    }

    function getChecked() {
        var ids = "";
        $("[name='mail-checkbox'][checked]").each(function () {
            ids += $(this).val() + ",";
        });
        return ids.substr(0, ids.length - 1);
    }

    function markRead(id) {
        var ids = id == "" || id == undefined ? getChecked() : id;
        if ("" == ids || undefined == ids) {
            top.bootbox.alert("请选择邮件！");
            return
        }
        $.ajax({
            url: "inbox/changeMassageState",
            data: {
                id: ids,
                //标记为已读 状态改为1
                state: 1
            },
            type: "POST",
            dataType: "json",
            success: function () {
                top.bootbox.alert("已标记为已读！");
                refresh();
            },
            error: function () {
                top.bootbox.alert("标记失败！");
            }
        });
    }

    function markTrashInbox(ids) {
        $.ajax({
            url: "inbox/changeMassageState",
            data: {
                id: ids,
                //标记为垃圾邮件 类型改为4
                state: 4
            },
            type: "POST",
            dataType: "json",
            success: function () {
                refresh();
                var $countTrash = $("#countTrash");
                var countTrash = $countTrash.val() - -1;
                $countTrash.val(countTrash);
                $("#countTrashBox").html("垃圾箱(" + countTrash + ")");
            },
            error: function () {
                top.bootbox.alert("更改失败！");
            }
        });
    }

    function markTrash() {
        var ids = getChecked();
        if ("" == ids || undefined == ids) {
            top.bootbox.alert("请选择邮件！");
            return
        }
        markTrashInbox(ids);
    }

    function delInbox(ids) {
        $.ajax({
            url: "inbox/delMassage",
            data: {
                id: ids
            },
            type: "POST",
            dataType: "json",
            success: function (r) {
                if (r) {
                    top.bootbox.alert("删除成功！");
                    refresh();
                } else {
                    top.bootbox.alert("删除失败！");
                }
            }
        });
    }

    function del() {
        var ids = getChecked();
        if ("" == ids || undefined == ids) {
            top.bootbox.alert("请选择邮件！");
            return
        }
        delInbox(ids);
    }

    function markDraft() {
        var ids = getChecked();
        if ("" == ids || undefined == ids) {
            top.bootbox.alert("请选择邮件！");
            return
        }
        $.ajax({
            url: "inbox/changeMassageCategory",
            data: {
                id: ids,
                //标记为垃圾邮件 类型改为4
                category: 3
            },
            type: "POST",
            dataType: "json",
            success: function (r) {
                if (r) {
                    top.bootbox.alert("删除成功！");
                    refresh();
                } else {
                    top.bootbox.alert("删除失败！");
                }
            }
        });
    }

</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>